//
//  NearlyViewController.m
//  littleLight's Project-A
//
//  Created by dllo on 16/5/19.
//  Copyright © 2016年 light. All rights reserved.
//

#import "NearlyViewController.h"
#import "WMPageController.h"
#import "AllThingsViewController.h"
#import "SceneryViewController.h"
#import "HotelViewController.h"
#import "RestaurantViewController.h"
#import "EntertainmentViewController.h"
#import "ShoppingViewController.h"
#define XGColor(r, g, b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1.0f]
@interface NearlyViewController ()

@end

@implementation NearlyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0 / 255.0 green:192 / 255.0 blue:203 / 255.0 alpha:1];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"Cancel2"] imageWithRenderingMode:1]style:UIBarButtonItemStylePlain target:self action:@selector(leftAction)];
    
    self.navigationItem.title = @"我的附近";
    //字体设为白色
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName: [UIFont systemFontOfSize:22]}];
    
    //不让scrollview偏到导航控制器里面
    [self setAutomaticallyAdjustsScrollViewInsets:NO];
    
    [self initMainViewController];
    
    
    
    
    
    
    
    
    
    
    
    
  
}

- (void)initMainViewController
{
    NSMutableArray *homeVCArr = [NSMutableArray array];
    NSMutableArray *homeVCTitleArr = [NSMutableArray array];
    for (int i = 0; i < 6; i++) {
        Class vcClass;
        NSString *title;
        switch (i) {
            case 0:
                vcClass = [AllThingsViewController class];
                title = @"全部";
                break;
            case 1:
                vcClass = [SceneryViewController class];
                title = @"景点";
                break;
            case 2:
                vcClass = [HotelViewController class];
                title = @"住宿";
                break;
            case 3:
                vcClass = [RestaurantViewController class];
                title = @"餐厅";
                break;
            case 4:
                vcClass = [EntertainmentViewController class];
                title = @"休闲娱乐";
                break;
            case 5:
                vcClass = [ShoppingViewController class];
                title = @"购物";
                break;
                
          
        }
        [homeVCArr addObject:vcClass];
        [homeVCTitleArr addObject:title];
        
    }
    WMPageController *homeVC = [[WMPageController alloc] initWithViewControllerClasses:homeVCArr andTheirTitles:homeVCTitleArr];
//    UINavigationController *homeNa = [[UINavigationController alloc] initWithRootViewController:homeVC];
    [homeVC.navigationController setNavigationBarHidden:YES animated:YES];
    homeVC.menuViewStyle = WMMenuViewStyleLine;
    homeVC.menuItemWidth = 80 * sWidth;
    homeVC.titleColorNormal = XGColor(45, 48, 53);
    homeVC.titleColorSelected = XGColor(63, 169, 213);
    homeVC.postNotification = YES;

  //  NSLog(@"SAF ");
    
    homeVC.view.frame = CGRectMake(0, 44 * sHeight, self.view.frame.size.width, self.view.frame.size.height);
    [self addChildViewController:homeVC];
    [self.view addSubview:homeVC.view];
    
}

- (void)leftAction
{
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
